package com.qs.javame.thread.join;

public class TestJoin5 extends Thread {

    /**
     * 自定义的join方法
     */
    public final void join2() {
        System.out.println(Thread.currentThread().getName() + "-执行join2()-1-" + isAlive());
        while (this.isAlive()) {
            System.out.println(Thread.currentThread().getName() + "-执行join2()-2-" + isAlive());
        }

        System.out.println(Thread.currentThread().getName() + "-执行join2()-1-2-" + isAlive());
    }

    @Override
    public void run() {
//        try {
//            sleep(3000);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
        System.out.println("my thread run over");
    }

    public static void main(String[] args) {
        TestJoin5 myThread = new TestJoin5();
        myThread.start();
        myThread.join2();
        System.out.println("main thread run over");
    }
}
